<?php

require_once($AppUI->getSystemClass('dp'));

class CQuotation_files extends CDpObject{

	var $qfile_id = NULL;
	var $qfile_quote = NULL;
	var $qfile_name = NULL;
	var $qfile_path = NULL;
	var $qfile_type = NULL;
	var $qfile_size = NULL;
	var $qfile_date = NULL;
	var $qfile_description = NULL;
	var $qfile_version = NULL;

    function CQuotation_files(){
    	$this->CDpObject('quotation_files', 'qfile_id');
    }

    // overload the delete method of the parent class for adaptation for quotations's needs
	function deleteById($id){
		$sql = 'DELETE FROM quotation_files WHERE qfile_id = ' . $id;
		// Delete file
		if (!db_exec($sql)) {
			return db_error();
		} else {
			return NULL;
		}
	}

	function getFileById($uid, $id){
		$q  = new DBQuery;
		$q->addTable('quotation_files');
		$q->addWhere('qfile_id = ' . $id);
		$q->addQuery('*');
		$sql = $q->prepare();
		$q->clear();
		return db_loadList($sql);
	}

	function getListByQuoteId($uid, $id){
		$q  = new DBQuery;
		$q->addTable('quotation_files');
		$q->addWhere('qfile_quote = ' . $id);
		$q->addQuery('*');
		$sql = $q->prepare();
		$q->clear();
		return db_loadList($sql);
	}
}
?>